package com.wits.qso.entity;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import net.sf.json.JSONObject;

import com.wits.platform.entity.BaseEntity;

@Entity
@Table(name = "QSO_CRECONTENT")
public class CreContent extends BaseEntity
{
	private String id = null;
	private Btable btId = null;
	private String aim = null;
	private String keynote = null;
	private MaterialD mtrdId = null;
	private HomeworkH hwkhId = null;
	private Aid aidId = null;
	
	public CreContent() { super(); }
	
	@Id
	@GenericGenerator(name = "idGen", strategy = "com.wits.platform.common.id.generator.IDGenerator", parameters = {
	        @Parameter(name = "segment_value", value = "QSO_CRECNT_ID"),
	        @Parameter(name = "table_name", value = "wits_id_generator"),
	        @Parameter(name = "value_column_name", value = "gen_value"), 
	        @Parameter(name = "segment_column_name", value = "gen_name"),
	        @Parameter(name = "segment_value_length", value = "5"), 
	        @Parameter(name = "sq_format", value = "%03d"),
	        @Parameter(name = "sq_prefix", value = "CL") })
	@GeneratedValue(generator = "idGen")
	@Column(name = "crecnt_id", nullable = false, insertable = true, updatable = false, length = 10)
	public String getId() {
		return id;
	}

	@ManyToOne
	@JoinColumn(name = "crecnt_btid", updatable = true)
	public Btable getBtId() {
		return btId;
	}

	@Column(name = "crecnt_aim", length = 1000)
	public String getAim() {
		return aim;
	}

	@Column(name = "crecnt_keynote", length = 1000)
	public String getKeynote() {
		return keynote;
	}

	@ManyToOne
	@JoinColumn(name = "crecnt_mtrdid", updatable = true)
	public MaterialD getMtrdId() {
		return mtrdId;
	}

	@ManyToOne
	@JoinColumn(name = "crecnt_hwkhid", updatable = true)
	public HomeworkH getHwkhId() {
		return hwkhId;
	}

	@ManyToOne 
	@JoinColumn(name = "crecnt_aidid", updatable = true)
	public Aid getAidId() {
		return aidId;
	}

	public void setId(String id) {
		this.id = id;
	}

	public void setBtId(Btable btId) {
		this.btId = btId;
	}

	public void setAim(String aim) {
		this.aim = aim;
	}

	public void setKeynote(String keynote) {
		this.keynote = keynote;
	}

	public void setMtrdId(MaterialD mtrdId) {
		this.mtrdId = mtrdId;
	}

	public void setHwkhId(HomeworkH hwkhId) {
		this.hwkhId = hwkhId;
	}

	public void setAidId(Aid aidId) {
		this.aidId = aidId;
	}

	@Override
	public String display() {
		// TODO Auto-generated method stub
		return null;
	}
	
	public String toString() {
		return JSONObject.fromObject( this, CreContent.getBaseJsonConfig() ).toString();
	}
}
